<!--
 * @Author: “Jackson” “1145239633@qq.com”
 * @Date: 2025-07-28 16:39:19
 * @LastEditors: “Jackson” “1145239633@qq.com”
 * @LastEditTime: 2025-10-28 10:26:59
 * @FilePath: \shaangu-web\src\views\fileManage\approveFile.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <el-dialog :title="ActTitle" :visible.sync="openCheck" :close-on-click-modal="false" width="1000px" append-to-body
    :show-close="false" v-dialogDrag>
    <el-form ref="form" :model="form" label-width="120px" class="addData">
      <el-form-item label="状态" prop="approverFlag">
        <div v-if="this.ActTitle == '校对'">
          <el-radio v-model="form.approverFlag" label="2">{{ ActTitle }}通过</el-radio>
          <el-radio v-model="form.approverFlag" label="4">{{ ActTitle }}不通过</el-radio>
        </div>
        <div v-else>
          <el-radio v-model="form.approverFlag" label="3">{{ ActTitle }}通过</el-radio>
          <el-radio v-model="form.approverFlag" label="4">{{ ActTitle }}不通过</el-radio>
        </div>
      </el-form-item>
      <el-form-item :label="ActTitle + '意见'" prop="approverReason">
        <el-input v-model="form.approverReason" placeholder="请输入意见" type="textarea" maxlength="100" show-word-limit
          rows="3" />
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="submitForm">确 定</el-button>
      <el-button @click="cancel">取 消</el-button>
    </div>
  </el-dialog>
</template>
<script>
import { taskverify, taskverification } from "@/api/fileManage/entering";
export default {
  props: ["openCheck", "rowId", "ActTitle"],
  data() {
    return {
      form: {
        approverReason: '',
        approverFlag: "",
      },
    };
  },
  watch: {
    openCheck: {
      handler(newVal) {
        if (newVal) { // 当对话框打开时
          this.resetForm(); // 清空表单
        }
      },
      immediate: true // 确保首次也能触发
    },
    ActTitle: {
      immediate: true,
      handler(newVal) {
        this.form.approverReason = undefined
        this.form.approverFlag = newVal === "校对" ? "2" : "3";
      },
    },
  },
  methods: {
    resetForm() {
      this.form = {
        approverReason: undefined,
        approverFlag: this.ActTitle == "校对" ? "2" : "3",
      };
    },
    submitForm() {
      this.form.id = this.rowId;
      if (this.ActTitle == "校对") {
        taskverify(this.form).then((res) => {
          this.$message.success("校对成功!");
          this.$emit("closeCheck", true);
        });
      } else {
        taskverification(this.form).then((res) => {
          this.$message.success(this.ActTitle + "成功!");
          this.$emit("closeCheck", true);
        });
      }
    },
    cancel() {
      this.$emit("closeCheck", false);
    },
  },
};
</script>
<style></style>
